#include<iostream>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;

class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        if(nums.empty()){
            return 0;
        }
        int index = 0;
        int pre = nums[index++];
        for(int i = 1;i<nums.size();++i){
            if(nums[i]==pre){
                
            }
            else{
                nums[index++] = nums[i];
                pre = nums[i];
            }
        }
        return index;
    }
};

int main(){
    Solution S;
    vector<int> nums = {0,0,1,1,1,2,2,3,3,4};
    cout<<S.removeDuplicates(nums)<<endl;
    return 0;
}